Skip to content

Support yarn 4 projects#5

Merged
adrianq merged 10 commits intomasterfrom
feature/support_yarn_4_projects
Mar 18, 2026
Merged

Support yarn 4 projects#5
adrianq merged 10 commits intomasterfrom
feature/support_yarn_4_projects

Conversation

@xurxodev
Copy link
Contributor

📌 References

📝 Implementation

Problem: In repos with "packageManager": "yarn@4.12.0" (e.g. dhis2-app-skeleton), the test job fails because the first use of yarn (e.g. in "Get yarn cache directory path") happens before Corepack is enabled, so the runner falls back to Yarn 1.x.

Changes in .github/workflows/app-test.yml:
Removed cache: "yarn" from the "Setup Node.js version from .nvmrc" step so yarn is not run before enabling Corepack.
Added an "Enable Corepack" step (corepack enable) right after setting up Node and before any yarn command.

Result: With Corepack enabled, repos without packageManager keep using Yarn 1.x; repos with packageManager use the specified version (e.g. Yarn 4). Dependency caching is unchanged and still done in "Get yarn cache directory path" and "Cache yarn dependencies".

📹 Screenshots/Screen capture

🔥 Testing

Run the workflow on a Yarn 1 repo (no packageManager): it should still pass.
Run the workflow on a Yarn 4 repo with packageManager (e.g. dhis2-app-skeleton): the "Unit tests" job should pass; previously it failed at "Setup Node.js version from .nvmrc" / "Get yarn cache directory path" with the Corepack error.

Avoid Corepack download message breaking the env file (tail -n1).
Avoids conflict with YARN_CACHE_DIR that yarn may set. Cache path
logic is unchanged.
- Enable Corepack so yarn 4 works (packageManager in package.json)
- Remove setup-node cache: 'yarn' to avoid YARN_CACHE_DIR conflict
- Add explicit yarn cache steps using ACTIONS_YARN_CACHE_PATH (same as app-test)
Copy link

@tokland tokland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In-line:

…che action to v5

  - keep manual Yarn cache flow so Corepack can be enabled before resolving Yarn 4
  - resolve cache path explicitly for Yarn 1 and Yarn 4 instead of parsing mixed output
  - upgrade Yarn and npm cache steps from actions/cache@v3 to v5
@xurxodev xurxodev requested a review from tokland March 17, 2026 05:55
@adrianq adrianq merged commit caab9b6 into master Mar 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants